﻿namespace KIMS;

/// <summary>
/// 系统配置类。
/// </summary>
public static class AppConfig
{
    /// <summary>
    /// 取得系统ID。
    /// </summary>
    public static string AppId => "TARGET_APPID";

    /// <summary>
    /// 取得系统名称。
    /// </summary>
    public static string AppName => "TARGET_APPNAME";

    /// <summary>
    /// 添加系统配置。
    /// </summary>
    /// <param name="services">服务集合。</param>
    public static void AddApplication(this IServiceCollection services)
    {
        Console.WriteLine(AppName);
#if DEBUG
        Config.IsDevelopment = true;
        Config.IsDebug = true;
#endif
        Config.RenderMode = RenderType.Auto;

        var assembly = typeof(AppConfig).Assembly;
        Config.AddModule(assembly);

        services.AddKnown(option =>
        {
            option.Id = AppId;
            option.Name = AppName;
        });
        services.AddModules();
        services.ConfigUI();
    }

    // 添加客户端
    internal static void AddApplicationClient(this IServiceCollection services, Action<ClientOption> action)
    {
        services.AddApplication();
        services.AddKnownClient(action);
    }

    private static void ConfigUI(this IServiceCollection services)
    {
        KStyleSheet.AddStyle("css/app.css");
    }
}